﻿using System.Linq.Expressions;

namespace System.Linq;

public static class IQueryableExtensions
{
    public static IQueryable<T> WhereIf<T>(this IQueryable<T> queryable, Func<bool> func,Expression<Func<T,bool>> predicate) where T : class
    {
        if (func())
        {
            return queryable.Where(predicate);
        }

        return queryable;
    }

    public static IQueryable<T> WhereIf<T>(this IQueryable<T> queryable, bool flag, Expression<Func<T, bool>> predicate) where T : class
    {
        if (flag)
        {
            return queryable.Where(predicate);
        }

        return queryable;
    }
}